package com.smart.reader.common;

import lombok.Data;

@Data
public class R<T> {
    private Integer code;
    private String message;
    private T data;

    // 成功，不带数据
    public static R<?> success(Integer code, String message) {
        R<?> result = new R<>();
        result.code = code;
        result.message = message;
        return result;
    }

    // 成功，带数据（这是您缺少的方法）
    public static <T> R<T> success(Integer code, String message, T data) {
        R<T> result = new R<>();
        result.code = code;
        result.message = message;
        result.data = data;
        return result;
    }

    // 失败，不带数据
    public static R<?> fail(Integer code, String message) {
        R<?> result = new R<>();
        result.code = code;
        result.message = message;
        return result;
    }

    // 失败，带数据
    public static <T> R<T> fail(Integer code, String message, T data) {
        R<T> result = new R<>();
        result.code = code;
        result.message = message;
        result.data = data;
        return result;
    }
}
